//
//  HJPayResultController.m
//  KaiChat
//
//  Created by lx on 2024/1/23.
//

#import "HJPayResultController.h"

@interface HJPayResultController ()

@end

@implementation HJPayResultController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.navigationBar.lineView.hidden = NO;
    self.navigationBar.title = @"Payment result";
    
    self.navigationController.viewControllers = @[self];
    
    UIImageView *iconImageView = [UIImageView addToView:self.view];
    iconImageView.image = [UIImage imageNamed: _isError ? @"payError": @"pay_succeed"];
    [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.width.height.offset(90);
        make.top.offset(KStatusBarHight + 100);
    }];
        
    UILabel *textLabel = [UILabel lableWithSuperView:self.view font:UIFontMediumMake(16) color:UIColor.tj_333333Color title: _isError ? @"Payment failed" : @"Payment successful" textAlignment:NSTextAlignmentLeft];
    [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(iconImageView.mas_bottom).offset(8);
        make.centerX.equalTo(iconImageView);
    }];
    
    UILabel *subTextLabel = [UILabel lableWithSuperView:self.view font:UIFontMake(12) color:UIColor.tj_BEBDCAColor title:[NSString stringWithFormat:@"Transfer to %@", _userName] textAlignment:NSTextAlignmentLeft];
    [subTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(iconImageView);
        make.top.equalTo(textLabel.mas_bottom).offset(2);
    }];

    HJStyle1Button *okButton = [HJStyle1Button buttonWithSuperView:self.view font:UIFontMediumMake(14) color:nil title:@"OK"];
    [okButton addTarget:self action:@selector(didClickOKButton) forControlEvents:UIControlEventTouchUpInside];
    [okButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.inset(58);
        make.height.offset(buttonHeight);
        make.top.equalTo(subTextLabel.mas_bottom).offset(30);
    }];
}

- (void)didClickOKButton {
    [self dismissToRootViewController:YES completion:nil];
}


@end
